package com.lottery.im.module.service.presenter;

import android.app.Activity;
import android.util.Log;
import com.lottery.im.MyApplication;
import com.lottery.im.api.ApiClient;
import com.lottery.im.api.observer.ShowTipListObserver;
import com.lottery.im.api.result.entity.bank.UserBankList;
import com.lottery.im.base.BaseFragmentPresenter;
import com.lottery.im.module.service.view.BankSelectView;
import com.trello.rxlifecycle2.LifecycleProvider;
import com.trello.rxlifecycle2.android.FragmentEvent;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * 作者：cyy
 * 时间：2018/9/26。
 */
public class BankSelectPresenter extends BaseFragmentPresenter<BankSelectView> {
  public BankSelectPresenter(Activity activity,
      BankSelectView iView,
      LifecycleProvider<FragmentEvent> provider) {
    super(activity, iView, provider);
  }

  String token = MyApplication.getInstance().getToken();
  String userId = MyApplication.getInstance().getUserInfo().getUserId();
  public void queryUserBankList(){
    ApiClient.getApiRetrofitInstance()
        .queryUserBankList(userId,token)
        .throttleFirst(2, TimeUnit.SECONDS)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .compose(provider.bindToLifecycle())
        .subscribe(new ShowTipListObserver<UserBankList>(activity) {
          @Override public void onSuccess(List<UserBankList> t) {
            iView.loadUserBankListSuccess(t);
          }
        });
  }
}
